/*
 author:叶林
 Data:2016-05-16
 Function:提示信息接口
 */

const express = require('express'),
    DbInit = require('../model/DbInit');


function recursion(list, pid) {
    var rtn = [];
    for(i in list) {
        if(list[i].parentid === pid) {
            rtn.push(list[i]);
            list[i].children = recursion(list, list[i].catid);

        }
    }
    return rtn;
}


exports.msgFormat = (reqdata, callback)=> {
    var url;
    url = rootConfig.backendurl + 'basClass/add?token=' + token;
    request.post({url: url, body: JSON.stringify(reqdata)}, (error, response, body)=> {
        var errMsg;
        winston.log('info', 'backendurl:' + url);
        if (!error && response.statusCode === 200) {
            if (JSON.parse(body).responseCode == 'false') {
                var apierr = {code: "000001", message: "添加班级信息 接口返回错误" + url};
                winston.log('error', apierr);
            }
            callback(null, body);
            winston.log('info', `添加班级信息成功: ${url}请求时间:${response.elapsedTime}ms`);

        } else {
            var errMsg = {code: "00000", message: "添加班级信息成功失败" + url};

            winston.log('error', errMsg);
            callback(errMsg, null);
        }
    });
};


/**
 * @function 获取栏目信息
 * @author yelin
 * @date 2018-08-08
 * @param parentid
 */
exports.getcatlist = (token, callback) => {

    let sequelize=DbInit.sequelize
    let obj={}
    let parentid=token
    let arr=[]
    sequelize.query('SELECT * FROM gps_category ORDER BY sortid',{type: sequelize.QueryTypes.SELECT}).then(function (results,err) {
        // SELECT query - use then
        if(err)
        {
            callback(obj, null);
        }else{
            if(results.length>0)
            {
                for(i in results)
                {
                    arr.push(results[i]);
                }

                let tree = recursion(arr, parentid);
                obj.return='0'
                obj.code='0'
                obj.message='获取栏目数据成功'
                obj.data=tree
                callback(null, obj)
            }
            else
            {
                obj.return='0'
                obj.code='0'
                obj.message='无效的参数'
                obj.data=[]
                console.trace('报错位置');
                callback(obj, null);
            }

        }
    })


};
exports.searchclass = (token, reqdata, callback)=> {
    var obj, url;
    obj = {
        pageNum: reqdata.pageNum ? reqdata.pageNum : "1",
        pageSize: reqdata.pageSize ? reqdata.pageSize : "10",
        schoolName: reqdata.schoolName ? reqdata.schoolName : "",
        className: reqdata.className ? reqdata.className : "",
        gradeName: reqdata.gradeName ? reqdata.gradeName : ""
    };
    url = rootConfig.backendurl + 'basClass/page?pageNum=' + obj.pageNum + '&pageSize=' + obj.pageSize + '&schoolName=' + obj.schoolName + '&className=' + obj.className + '&gradeName=' + obj.gradeName + '&token=' + token;
    request.get({url: url}, (error, response, body)=> {
        if (!error && response.statusCode === 200) {
            if (JSON.parse(body).responseCode == 'false') {
                var apierr = {code: "000001", message: "班级模块渲染 接口返回错误" + url};
                winston.log('error', apierr);
            }
            callback(null, JSON.parse(body));
            winston.log('info', `班级模块渲染成功: ${url}请求时间:${response.elapsedTime}ms`);
        } else {
            var errMsg = {code: "00000", message: "班级模块渲染失败" + url};
            winston.log('error', errMsg);
            callback(errMsg, null);
        }
    });
};

exports.editClass = (token, reqdata, callback)=> {
    var url;
    url = rootConfig.backendurl + 'basClass/update?token=' + token;
    request.put({url: url, body: JSON.stringify(reqdata)}, (error, response, body)=> {
        var errMsg;
        winston.log('info', 'backendurl:' + url);
        if (!error && response.statusCode === 200) {
            if (JSON.parse(body).responseCode == 'false') {
                var apierr = {code: "000001", message: "编辑班级 接口返回错误" + url};
                winston.log('error', apierr);
            }
            callback(null, body);
            winston.log('info', `编辑班级信息成功: ${url}请求时间:${response.elapsedTime}ms`);
        } else {
            var errMsg = {code: "00000", message: "编辑班级信息失败" + url};
            winston.log('error', errMsg);
            callback(errMsg, null);
        }
    });
};

exports.addSchool = (token, reqdata, callback)=> {
    var url;
    url = rootConfig.backendurl + 'basSchool/add?token=' + token;
    request.post({url: url, body: JSON.stringify(reqdata)}, (error, response, body)=> {
        var errMsg;
        winston.log('info', 'backendurl:' + url);
        if (!error && response.statusCode === 200) {
            if (JSON.parse(body).responseCode == 'false') {
                var apierr = {code: "000001", message: "添加学校信息 接口返回错误" + url};
                winston.log('error', apierr);
            }
            callback(null, body);
            winston.log('info', `添加学校信息成功: ${url}请求时间:${response.elapsedTime}ms`);
        } else {
            var errMsg = {code: "00000", message: "添加学校信息失败" + url};
            winston.log('error', errMsg);
            callback(errMsg, null);
        }
    });
};

exports.searchSchool = (token, reqdata, callback)=> {
    var obj, url;
    obj = {
        pageNum: reqdata.pageNum ? reqdata.pageNum : "1",
        pageSize: reqdata.pageSize ? reqdata.pageSize : "10",
        schoolName: reqdata.schoolName ? reqdata.schoolName : "",
        districtCode: reqdata.districtCode ? reqdata.districtCode : "",
        stageName: reqdata.stageName ? reqdata.stageName : "",
        schoolType: reqdata.schoolType ? reqdata.schoolType : "",
        schoolLevel: reqdata.schoolLevel ? reqdata.schoolLevel : "",
        schoolHandlesort: reqdata.schoolHandlesort ? reqdata.schoolHandlesort : ""
    };
    url = rootConfig.backendurl + 'basSchool/page?pageNum=' + obj.pageNum + '&pageSize=' + obj.pageSize + '&schoolName=' +obj.schoolName + '&districtCode=' + obj.districtCode + '&stageName=' + obj.stageName + '&schoolType=' + obj.schoolType + '&schoolLevel=' + obj.schoolLevel + '&schoolHandlesort=' + obj.schoolHandlesort + '&token=' + token;
    return request.get({
        url: url
    }, (error, response, body)=> {
        var errMsg;
        winston.log('info', 'backendurl:' + url);
        if (!error && response.statusCode === 200) {
            if (JSON.parse(body).responseCode == 'false') {
                var apierr = {code: "000001", message: "学校模块渲染信息 接口返回错误" + url};
                winston.log('error', apierr);
            }
            callback(null, JSON.parse(body));
            return winston.log('info', `学校模块渲染成功: ${url}请求时间:${response.elapsedTime}ms`);
        } else {
            var errMsg = {code: "00000", message: "学校模块渲染失败" + url};
            winston.log('error', errMsg);
            return callback(errMsg, null);
        }
    });
};

exports.searchAllSchool = (token, callback)=> {
    var url;
    url = rootConfig.backendurl + 'basSchool/list?status=1&token=' + token;
    return request.get({
        url: url
    }, (error, response, body)=> {
        var errMsg;
        winston.log('info', 'backendurl:' + url);
        if (!error && response.statusCode === 200) {
            if (JSON.parse(body).responseCode == 'false') {
                var apierr = {code: "000001", message: "根据状态查询所有学校信息 接口返回错误" + url};
                winston.log('error', apierr);
            }
            callback(null, body);
            return winston.log('info', `根据状态查询所有学校信息成功: ${url}请求时间:${response.elapsedTime}ms`);

        } else {
            var errMsg = {code: "00000", message: "根据状态查询所有学校失败" + url};
            winston.log('error', errMsg);
            return callback(errMsg, null);
        }
    });
};

exports.editSchool = (token, reqdata, callback)=> {
    var url;
    url = rootConfig.backendurl + 'basSchool/update?token=' + token;
    request.put({url: url, body: JSON.stringify(reqdata)}, (error, response, body)=> {
        var errMsg;
        winston.log('info', 'backendurl:' + url);
        if (!error && response.statusCode === 200) {
            if (JSON.parse(body).responseCode == 'false') {
                var apierr = {code: "000001", message: "编辑学校信息 接口返回错误" + url};
                winston.log('error', apierr);
            }
            callback(null, body);
            return winston.log('info', `编辑学校信息成功: ${url}请求时间:${response.elapsedTime}ms`);
        } else {
            var errMsg = {code: "00000", message: "编辑学校信息失败" + url};
            winston.log('error', errMsg);
            callback(errMsg, null);
        }
    });
};

exports.delSchool = (token, pkid, callback)=> {
    var url;
    url = rootConfig.backendurl + 'basSchool/status?ids=' + pkid + '&status=0' + '&token=' + token;
    request.put({url: url}, (error, response, body)=> {
        var errMsg;
        winston.log('info', 'backendurl:' + url);
        if (!error && response.statusCode === 200) {
            if (JSON.parse(body).responseCode == 'false') {
                var apierr = {code: "000001", message: "删除学校信息 接口返回错误" + url};
                winston.log('error', apierr);
            }
            callback(null, body);
            return winston.log('info', `编辑学校信息成功: ${url}请求时间:${response.elapsedTime}ms`);
        }
        else {
            var errMsg = {code: "00000", message: "删除学校信息失败" + url};
            winston.log('error', errMsg);
            callback(errMsg, null);
        }
    });
};


exports.searchSchoolCategory = function (reqdata, callback) {
    var url;
    url = rootConfig.sjq_emi +  'rest/webemi/getCode?token=sXdcjQtz&basecode=xxlb';
    return request.get({
        url: url
    }, (error, response, body)=> {
        var errMsg;
        winston.log('info', 'backendurl:' + url);
        if (!error && response.statusCode === 200) {
            if (JSON.parse(body).responseCode == 'false') {
                var apierr = {code: "000001", message: "学校模块查询学校类别成功 接口返回错误" + url};
                winston.log('error', apierr);
            }
            callback(null, body);
            return winston.log('info', `学校模块查询学校类别成功: ${url}请求时间:${response.elapsedTime}ms`);

        } else {
            var errMsg = {code: "00000", message: "学校模块查询学校类别失败" + url};
            winston.log('error', errMsg);
            return callback(errMsg, null);
        }
    });
};

exports.searchSchoolLevel = function (reqdata, callback) {
    var url;
    url = rootConfig.sjq_emi + 'rest/webemi/getCode?token=sXdcjQtz&basecode=sjq_edu_bas_00002';
    return request.get({
        url: url
    }, (error, response, body)=> {
        var errMsg;
        winston.log('info', 'backendurl:' + url);
        if (!error && response.statusCode === 200) {
            if (JSON.parse(body).responseCode == 'false') {
                var apierr = {code: "000001", message: "学校模块查询学校级别 接口返回错误" + url};
                winston.log('error', apierr);
            }
            callback(null, body);
            return winston.log('info', `学校模块查询学校级别成功: ${url}请求时间:${response.elapsedTime}ms`);

        } else {

            var errMsg = {code: "00000", message: "学校模块查询学校级别失败" + url};
            winston.log('error', errMsg);
            return callback(errMsg, null);
        }
    });
};

exports.searchSchoolHandlesort = function (reqdata, callback) {
    var url;
    url = rootConfig.sjq_emi + 'rest/webemi/getCode?token=sXdcjQtz&basecode=xxbb';
    request.get({url: url}, (error, response, body)=> {
        var errMsg;
        winston.log('info', 'backendurl:' + url);
        if (!error && response.statusCode === 200) {
            if (JSON.parse(body).responseCode == 'false') {
                var apierr = {code: "000001", message: "学校模块查询学校办别 接口返回错误" + url};
                winston.log('error', apierr);
            }
            callback(null, body);
            return winston.log('info', `学校模块查询学校办别成功: ${url}请求时间:${response.elapsedTime}ms`);
        } else {
            var errMsg = {code: "00000", message: "学校模块查询学校办别失败" + url};
            winston.log('error', errMsg);
            callback(errMsg, null);
        }
    });
};

exports.addDistrict = (token, reqdata, callback)=> {
    var url;
    url = rootConfig.backendurl + 'basDistrict/add?token=' + token;
    request.post({url: url, body: JSON.stringify(reqdata)}, (error, response, body)=> {
        var errMsg;
        winston.log('info', 'backendurl:' + url);
        if (!error && response.statusCode === 200) {
            if (JSON.parse(body).responseCode == 'false') {
                var apierr = {code: "000001", message: "添加区域信息 接口返回错误" + url};
                winston.log('error', apierr);
            }
            callback(null, body);
            winston.log('info', `添加区域信息成功: ${url}请求时间:${response.elapsedTime}ms`);
        } else {
            var errMsg = {code: "00000", message: "添加区域信息失败" + url};
            winston.log('error', errMsg);
            callback(errMsg, null);
        }
    });
};

exports.searchDistrict = (token, reqdata, callback)=> {
    var obj, url;
    obj = {
        pageNum: reqdata.pageNum ? reqdata.pageNum : "1",
        pageSize: reqdata.pageSize ? reqdata.pageSize : "10",
        districtName: reqdata.districtName ? reqdata.districtName : "",
        schoolLevel: reqdata.schoolLevel ? reqdata.schoolLevel : "",
        districtShortname: reqdata.districtShortname ? reqdata.districtShortname : ""
    };
    url = rootConfig.backendurl + 'basDistrict/page?pageNum=' + obj.pageNum + '&pageSize=' + obj.pageSize + '&districtName=' + encodeURI(obj.districtName) + '&districtName=' + encodeURI(obj.districtName) + '&schoolLevel=' + encodeURI(obj.schoolLevel) + '&districtShortname=' + encodeURI(obj.districtShortname) + '&token=' + token;
    return request.get({
        url: url
    }, (error, response, body)=> {
        var errMsg;
        winston.log('info', 'backendurl:' + url);
        if (!error && response.statusCode === 200) {
            if (JSON.parse(body).responseCode == 'false') {
                var apierr = {code: "000001", message: "区域模块渲染 接口返回错误" + url};
                winston.log('error', apierr);
            }
            callback(null, JSON.parse(body));
            winston.log('info', `区域模块渲染成功: ${url}请求时间:${response.elapsedTime}ms`);
        } else {
            var errMsg = {code: "00000", message: "区域模块渲染失败" + url};
            winston.log('error', errMsg);
            return callback(errMsg, null);
        }
    });
};

exports.editDistrict = function (token, reqdata, callback) {
    var url;
    url = rootConfig.backendurl + 'basDistrict?token=' + token;
    request.put({url: url, body: JSON.stringify(reqdata)}, (error, response, body)=> {
        var errMsg;
        winston.log('info', 'backendurl:' + url);
        if (!error && response.statusCode === 200) {
            if (JSON.parse(body).responseCode == 'false') {
                var apierr = {code: "000001", message: "编辑区域信息 接口返回错误" + url};
                winston.log('error', apierr);
            }
            callback(null, body);
            winston.log('info', `编辑区域信息成功: ${url}请求时间:${response.elapsedTime}ms`);
        } else {
            var errMsg = {code: "00000", message: "编辑区域信息失败" + url};
            winston.log('error', errMsg);
            callback(errMsg, null);
        }
    });
};

exports.delDistrict = function (token, pkid, callback) {
    var url;
    url = rootConfig.backendurl + 'basDistrict/status?ids=' + pkid + '&status=0' + '&token=' + token;
    request.put({url: url}, (error, response, body)=> {
        var errMsg;
        winston.log('info', 'backendurl:' + url);
        if (!error && response.statusCode === 200) {
            if (JSON.parse(body).responseCode == 'false') {
                var apierr = {code: "000001", message: "删除区域信息 接口返回错误" + url};
                winston.log('error', apierr);
            }
            callback(null, body);
            winston.log('info', `删除区域信息成功: ${url}请求时间:${response.elapsedTime}ms`);
        } else {
            var errMsg = {code: "00000", message: "删除区域信息失败" + url};
            winston.log('error', errMsg);
            callback(errMsg, null);
        }
    });
};

exports.searchdistrictLevel = (token, callback)=> {
    var url;
    url = rootConfig.sjq_emi + 'rest/webemi/getCode?token=sXdcjQtz&basecode=sjq_edu_bas_00005';
    return request.get({
        url: url
    }, (error, response, body)=> {
        var errMsg;
        winston.log('info', 'backendurl:' + url);
        if (!error && response.statusCode === 200) {
            if (JSON.parse(body).responseCode == 'false') {
                var apierr = {code: "000001", message: "区域模块查询区域级别 接口返回错误" + url};
                winston.log('error', apierr);
            }
            callback(null, body);
            winston.log('info', `区域模块查询区域级别成功: ${url}请求时间:${response.elapsedTime}ms`);
        } else {
            var errMsg = {code: "00000", message: "区域模块查询区域级别失败" + url};
            winston.log('error', errMsg);
            return callback(errMsg, null);
        }
    });
};

exports.addTeacher = function (token, reqdata, callback) {
    var url;
    url = rootConfig.backendurl + 'basTeacher/add?token=' + token;
    request.post({url: url, body: JSON.stringify(reqdata)}, (error, response, body)=> {
        var errMsg;
        winston.log('info', 'backendurl:' + url);
        if (!error && response.statusCode === 200) {
            callback(null, body);
            winston.log('info', 'invoke add class success');
        } else {
            errMsg = {
                "code": "00000",
                "message": "invoke add class error!"
            };
            winston.log('error', errMsg);
            callback(errMsg, null);
        }
    });
};

exports.searchTeacher = (token, reqdata, callback)=> {
    var obj, url;
    obj = {
        pageNum: reqdata.pageNum ? reqdata.pageNum : "1",
        pageSize: reqdata.pageSize ? reqdata.pageSize : "10",
        teacherName: reqdata.teacherName ? reqdata.teacherName : "",
        schoolName: reqdata.schoolName ? reqdata.schoolName : "",
        schoolCode: reqdata.schoolCode ? reqdata.schoolCode : "",
        titleMark: reqdata.titleMark ? reqdata.titleMark : ""
    };
    url = rootConfig.backendurl + 'basTeacher/page?pageNum=' + obj.pageNum + '&pageSize=' + obj.pageSize + '&teacherName=' + obj.teacherName + '&schoolName=' + obj.schoolName + '&schoolCode=' + obj.schoolCode + '&titleMark=' + obj.titleMark + '&token=' + token;
    return request.get({
        url: url
    }, (error, response, body)=> {
        body=JSON.parse(body)
        if (!error && response.statusCode === 200) {
            winston.log('info', `教师分页模块渲染成功: ${url}请求时间:${response.elapsedTime}ms`);
            if(body.responseCode=="false"){
                var apierr={code:"00001",message:"教师模块分页查询接口返回错误" + url};
                winston.log('error',apierr);
            }
            callback(null, body);
        } else {
            var errMsg = {code: "00000", message: "教师分页模块渲染失败" + url};
            winston.log('error', errMsg);
            return callback(errMsg, null);
        }
    });
};


exports.editTeacher = function (token, reqdata, callback) {
    var url;
    url = rootConfig.backendurl + 'basTeacher/update?token=' + token;
    request.put({url: url, body: JSON.stringify(reqdata)}, (error, response, body)=> {
        winston.log('info', 'backendurl:' + url);
        if (!error && response.statusCode === 200) {
            winston.log('info', `修改教师信息成功: ${url}请求时间:${response.elapsedTime}ms`);
            if(JSON.parse(body).responseCode=='false'){
                winston.log('info','修改教师信息接口返回错误' +url)
            }
            callback(null, body);
        } else {
            var errMsg = {code: "00000", message: "修改教师信息失败" + url};
            winston.log('error', errMsg);
            callback(errMsg, null);
        }
    });
};

exports.delTeacher = function (token, pkid, callback) {
    var url;
    url = rootConfig.backendurl + 'basTeacher/status?ids=' + pkid + '&status=0&token=' + token;
    request.put({url: url}, (error, response, body)=> {
        winston.log('info', 'backendurl:' + url);
        if (!error && response.statusCode === 200) {
            winston.log('info', `删除教师信息成功: ${url}请求时间:${response.elapsedTime}ms`);
            if(JSON.parse(body).responseCode=='false'){
                winston.log('info','删除教师信息接口返回错误' +url)
            }
            callback(null, body);
        } else {
            var errMsg = {code: "00000", message: "删除教师信息失败" + url};
            winston.log('error', errMsg);
            callback(errMsg, null);
        }
    });
};
//查看证件类型
exports.searchCertType = (token, callback)=> {
    var url;
    url = rootConfig.sjq_emi + 'rest/webemi/getCode?token=sXdcjQtz&basecode=sfzjlx';
    return request.get({
        url: url
    }, (error, response, body)=> {
        winston.log('info', 'backendurl:' + url);
        if (!error && response.statusCode === 200) {
            winston.log('info', `查看证件类型成功: ${url}请求时间:${response.elapsedTime}ms`);
            if(JSON.parse(body).responseCode=='false'){
                winston.log('info','查看证件类型接口返回错误' +url)
            }
            callback(null, body);
        } else {
            var errMsg = {code: "00000", message: "查看证件类型失败" + url};
            winston.log('error', errMsg);
            return callback(errMsg, null);
        }
    });
};
//查看用户类型----家长模块

exports.searchUserType = (token, callback)=> {
    var url;
    url = rootConfig.sjq_emi + 'rest/webemi/getCode?token=sXdcjQtz&basecode=sjq_pms_0007';
    return request.get({
        url: url
    }, (error, response, body)=> {
        winston.log('info', 'backendurl:' + url);
        if (!error && response.statusCode === 200) {
            if(JSON.parse(body).responseCode=='false'){
                winston.log('info','家长模块查询用户类型接口返回错误' +url)
            }
            winston.log('info', `家长模块查询用户类型成功: ${url}请求时间:${response.elapsedTime}ms`);
            callback(null, body);
        } else {

            var errMsg = {code: "00000", message: "家长模块查询用户类型失败" + url};
            winston.log('error', errMsg);
            return callback(errMsg, null);
        }
    });
};

exports.addStudent = function (token, reqdata, callback) {
    var url;
    url = rootConfig.backendurl + 'basStudent/add?token=' + token;
    request.post({url: url, body: JSON.stringify(reqdata)}, (error, response, body)=> {
        winston.log('info', 'backendurl:' + url);
        if (!error && response.statusCode === 200) {
            winston.log('info', `添加学生信息成功: ${url}请求时间:${response.elapsedTime}ms`);
            if(JSON.parse(body).responseCode=='false'){
                winston.log('info','添加学生信息接口返回错误' +url)
            }
            callback(null, body);
        } else {
            var errMsg = {code: "00000", message: "添加学生信息失败" + url};
            winston.log('error', errMsg);
            callback(errMsg, null);
        }
    });
};

exports.searchStudent = (token, reqdata, callback)=> {
    var obj, url;
    obj = {
        pageNum: reqdata.pageNum ? reqdata.pageNum : "1",
        pageSize: reqdata.pageSize ? reqdata.pageSize : "10",
        studentName: reqdata.studentName ? reqdata.studentName : "",
        schoolName: reqdata.schoolName ? reqdata.schoolName : "",
        className: reqdata.className ? reqdata.className : "",
        schoolStart: reqdata.schoolStart ? reqdata.schoolStart : "",
        schoolEnd: reqdata.schoolEnd ? reqdata.schoolEnd : "",
        classCode: reqdata.classCode ? reqdata.classCode : "",
    };
    url = rootConfig.backendurl + 'basStudent/page?pageNum=' + obj.pageNum + '&pageSize=' + obj.pageSize + '&studentName=' + obj.studentName + '&schoolName=' + obj.schoolName + '&className=' + obj.className + '&schoolStart=' + obj.schoolStart + '&schoolEnd=' + obj.schoolEnd + '&classCode=' + obj.classCode + '&token=' + token;
    request.get({url: url}, (error, response, body)=> {
        winston.log('info', 'backendurl:' + url);
        if (!error && response.statusCode === 200) {
            if(JSON.parse(body).responseCode=='false'){
                winston.log('info','添加学生信息接口返回错误' +url)
            }
            winston.log('info', `学生模块分页渲染成功: ${url}请求时间:${response.elapsedTime}ms`);
            callback(null, JSON.parse(body));
        } else {
            var errMsg = {code: "00000", message: "学生模块分页渲染失败" + url};
            winston.log('error', errMsg);
            callback(errMsg, null);
        }
    });
};

exports.editStudent = function (token, reqdata, callback) {
    var url;
    url = rootConfig.backendurl + 'basStudent/update?token=' + token;
    request.put({url: url, body: JSON.stringify(reqdata)}, (error, response, body)=> {
        winston.log('info', 'backendurl:' + url);
        if (!error && response.statusCode === 200) {
            winston.log('info', `修改学生信息成功: ${url}请求时间:${response.elapsedTime}ms`);
            if(JSON.parse(body).responseCode=='false'){
                winston.log('info','添加学生信息接口返回错误' +url)
            }
            callback(null, body);
        } else {
            var errMsg = {code: "00000", message: "修改学生信息失败" + url};
            winston.log('error', errMsg);
            callback(errMsg, null);
        }
    });
};

exports.delStudent = function (token, pkId, callback) {
    var url;
    url = rootConfig.backendurl + 'basStudent/status?ids=' + pkId + '&status=0' + '&token=' + token;
    request.put({url: url}, (error, response, body)=> {
        winston.log('info', 'backendurl:' + url);
        if (!error && response.statusCode === 200) {
            if(JSON.parse(body).responseCode=='false'){
                winston.log('info','删除学生信息接口返回错误' +url)
            }
            winston.log('info', `删除学生信息成功: ${url}请求时间:${response.elapsedTime}ms`);
            callback(null, body);
        } else {
            var errMsg = {code: "00000", message: "删除学生信息失败" + url};
            winston.log('error', errMsg);
            return callback(errMsg, null);
        }
    });
};

exports.addAbility = function (token, reqdata, callback) {
    var url;
    url = rootConfig.backendurl + 'basAbility/add?token=' + token;
    request.post({url: url, body: JSON.stringify(reqdata)}, (error, response, body)=> {
        winston.log('info', 'backendurl:' + url);
        if (!error && response.statusCode === 200) {
            if(JSON.parse(body).responseCode=='false'){
                winston.log('info','添加能力信息接口返回错误' +url)
            }
            winston.log('info', `添加能力信息成功: ${url}请求时间:${response.elapsedTime}ms`);
            callback(null, body);
        } else {
            var errMsg = {code: "00000", message: "添加能力信息失败" + url};
            winston.log('error', errMsg);
            callback(errMsg, null);
        }
    });
};

exports.searchAbility = (token, reqdata, callback)=> {
    var url;
    url = rootConfig.backendurl + 'basAbility/page?pageNum=' + reqdata.pagenum + '&pageSize=' + reqdata.pagesize + '&token=' + token;
    request.get({url: url}, (error, response, body)=> {
        winston.log('info', 'backendurl:' + url);
        if (!error && response.statusCode === 200) {
            if(JSON.parse(body).responseCode=='false'){
                winston.log('info','查询能力分页信息接口返回错误' +url)
            }
            winston.log('info', `查询能力分页信息成功: ${url}请求时间:${response.elapsedTime}ms`);
            callback(null, body);
        }
        else{
            var errMsg = {code: "00000", message: "查询能力分页信息失败" + url};
            winston.log('error', errMsg);
            callback(errMsg, null);
        }
    });
};

exports.editAbility = function (token, reqdata, callback) {
    var url;
    url = rootConfig.backendurl + 'basAbility/update?token=' + token;
    request.put({url: url, body: JSON.stringify(reqdata)}, (error, response, body)=> {
        var errMsg;
        winston.log('info', 'backendurl:' + url);
        if (!error && response.statusCode === 200) {
            if(JSON.parse(body).responseCode=='false'){
                winston.log('info','修改信息成功接口返回错误' +url)
            }
            callback(null, body);
            winston.log('info', `修改能力信息成功: ${url}请求时间:${response.elapsedTime}ms`);
        } else {
            var errMsg = {code: "00000", message: "修改能力信息失败" + url};
            winston.log('error', errMsg);
            callback(errMsg, null);
        }
    });
};

exports.delAbility = function (token, pkid, callback) {
    var url;
    url = rootConfig.backendurl + 'basAbility/status?ids=' + pkid + '&status=0' + '&token=' + token;
    return request.put({
        url: url
    }, (error, response, body)=> {
        var errMsg;
        winston.log('info', 'backendurl:' + url);
        if (!error && response.statusCode === 200) {
            if(JSON.parse(body).responseCode=='false'){
                winston.log('info','删除能力信息接口返回错误' +url)
            }
            callback(null, body);
            winston.log('info', `删除能力信息成功: ${url}请求时间:${response.elapsedTime}ms`);
        } else {
            var errMsg = {code: "00000", message: "删除能力信息失败" + url};
            winston.log('error', errMsg);
            return callback(errMsg, null);
        }
    });
};

exports.addCriterion = function (token, reqdata, callback) {
    var url;
    url = rootConfig.backendurl + 'basCriterion/add?token=' + token;
    request.post({url: url, body: JSON.stringify(reqdata)}, (error, response, body)=> {
        var errMsg;
        winston.log('info', 'backendurl:' + url);
        if (!error && response.statusCode === 200) {
            if(JSON.parse(body).responseCode=='false'){
                winston.log('info','添加课标信息接口返回错误' +url)
            }
            callback(null, body);
            winston.log('info', `添加课标信息成功: ${url}请求时间:${response.elapsedTime}ms`);
        }
        else {
            var errMsg = {code: "00000", message: "添加课标信息失败" + url};
            winston.log('error', errMsg);
            callback(errMsg, null);
        }
    });
};

exports.searchCriterion = (token, reqdata, callback)=> {
    var obj, url;
    obj = {
        pageNum: reqdata.pageNum ? reqdata.pageNum : "1",
        pageSize: reqdata.pageSize ? reqdata.pageSize : "10",
        criterionName: reqdata.criterionName ? reqdata.criterionName : "",
        stageName: reqdata.stageName ? reqdata.stageName : "",
        subjectName: reqdata.subjectName ? reqdata.subjectName : "",
        criterionCode: reqdata.criterionCode ? reqdata.criterionCode : ""
    };
    url = rootConfig.backendurl + 'basCriterion/page?pageNum=' + obj.pageNum + '&pageSize=' + obj.pageSize + '&criterionName=' +obj.criterionName + '&stageName=' + obj.stageName + '&subjectName=' + obj.subjectName + '&criterionCode=' + obj.criterionCode + '&token=' + token;
    request.get({url: url}, (error, response, body)=> {
        var errMsg;
        winston.log('info', 'backendurl:' + url);
        if (!error && response.statusCode === 200) {
            if(JSON.parse(body).responseCode=='false'){
                winston.log('info','查询课标分页接口返回错误' +url)
            }
            callback(null, JSON.parse(body));
            winston.log('info', `课标模块渲染成功: ${url}请求时间:${response.elapsedTime}ms`);
        } else {
            var errMsg = {code: "00000", message: "课标模块渲染失败" + url};
            winston.log('error', errMsg);
            callback(errMsg, null);
        }
    });
};

exports.editCriterion = function (token, reqdata, callback) {
    var url;
    url = rootConfig.backendurl + 'basCriterion/update?token=' + token;
    request.put({url: url, body: JSON.stringify(reqdata)}, (error, response, body)=> {
        winston.log('info', 'backendurl:' + url);
        if (!error && response.statusCode === 200) {
            if(JSON.parse(body).responseCode=='false'){
                winston.log('info','编辑课标信息接口返回错误' +url)
            }
            callback(null, body);
            winston.log('info', `编辑课标信息成功: ${url}请求时间:${response.elapsedTime}ms`);
        } else {
            var errMsg = {code: "00000", message: "编辑课标信息失败" + url};
            winston.log('error', errMsg);
            callback(errMsg, null);
        }
    });
};

exports.delCriterion = function (token, pkId, callback) {
    var url;
    url = rootConfig.backendurl + 'basCriterion/status?ids=' + pkId + '&status=0' + '&token=' + token;
    return request.put({
        url: url
    }, (error, response, body)=> {
        var errMsg;
        winston.log('info', 'backendurl:' + url);
        if (!error && response.statusCode === 200) {
            if(JSON.parse(body).responseCode=='false'){
                winston.log('info','删除课标信息接口返回错误' +url)
            }
            callback(null, body);
            winston.log('info', `删除课标信息成功: ${url}请求时间:${response.elapsedTime}ms`);
        } else {
            var errMsg = {code: "00000", message: "删除课标信息失败" + url};
            winston.log('error', errMsg);
            return callback(errMsg, null);
        }
    });
};

/**
 * 根据学段查询学科信息
 * author:丽云
 */
exports.findSubjectByStageCode = (stageCode, token, callback)=> {
    var url;
    url = rootConfig.backendurl + 'BasStage/findSubjectByStageCode?stageCode=' + stageCode + '&token=' + token;
    ;
    request.get({url: url}, (error, response, body)=> {
        var errMsg;
        winston.log('info', 'backendurl:' + url);
        if (!error && response.statusCode === 200) {
            if(JSON.parse(body).responseCode=='false'){
                winston.log('info','根据学段查询学科信息接口返回错误' +url)
            }
            callback(null, body);
            winston.log('info', `根据学段查询学科信息成功: ${url}请求时间:${response.elapsedTime}ms`);
        } else {
            var errMsg = {code: "00000", message: "根据学段查询学科信息失败" + url};
            winston.log('error', errMsg);
            callback(errMsg, null);
        }
    });
};

exports.addDifficulty = function (token, reqdata, callback) {
    var url;
    url = rootConfig.backendurl + 'basDifficulty/add?token=' + token;
    request.post({url: url, body: JSON.stringify(reqdata)}, (error, response, body)=> {
        var errMsg;
        winston.log('info', 'backendurl:' + url);
        if (!error && response.statusCode === 200) {
            if(JSON.parse(body).responseCode=='false'){
                winston.log('info','添加难度信息接口返回错误' +url)
            }
            callback(null, body);
            winston.log('info', `添加难度信息成功: ${url}请求时间:${response.elapsedTime}ms`);

        } else {
            var errMsg = {code: "00000", message: "添加难度信息失败" + url};
            winston.log('error', errMsg);
            callback(errMsg, null);
        }
    });
};

exports.searchDifficulty = (token, reqdata, callback)=> {
    var url;
    url = rootConfig.backendurl + 'basDifficulty/list?status=1&token=' + token;
    request.get({url: url}, (error, response, body)=> {
        var errMsg;
        winston.log('info', 'backendurl:' + url);
        if (!error && response.statusCode === 200) {
            if(JSON.parse(body).responseCode=='false'){
                winston.log('info','查询难度信息接口返回错误' +url)
            }
            callback(null, body);
            winston.log('info', `查询难度信息成功: ${url}请求时间:${response.elapsedTime}ms`);
        } else {
            var errMsg = {code: "00000", message: "查询难度信息失败" + url};
            winston.log('error', errMsg);
            callback(errMsg, null);
        }
    });
};

exports.editDifficulty = function (token, reqdata, callback) {
    var url;
    url = rootConfig.backendurl + 'basDifficulty/update?token=' + token;
    return request.put({
        url: url,
        body: JSON.stringify(reqdata)
    }, (error, response, body)=> {
        var errMsg;
        winston.log('info', 'backendurl:' + url);
        if (!error && response.statusCode === 200) {
            if(JSON.parse(body).responseCode=='false'){
                winston.log('info','编辑难度信息接口返回错误' +url)
            }
            callback(null, body);
            winston.log('info', `编辑难度信息成功: ${url}请求时间:${response.elapsedTime}ms`);

        } else {
            var errMsg = {code: "00000", message: "编辑难度信息失败" + url};
            winston.log('error', errMsg);
            return callback(errMsg, null);
        }
    });
};

exports.delDifficulty = function (pkid, token, callback) {
    var url;
    url = rootConfig.backendurl + 'basDifficulty/status?ids=' + pkid + '&status=0&token=' + token;
    return request.put({
        url: url
    }, (error, response, body)=> {
        var errMsg;
        winston.log('info', 'backendurl:' + url);
        if (!error && response.statusCode === 200) {
            if(JSON.parse(body).responseCode=='false'){
                winston.log('info','删除难度信息接口返回错误' +url)
            }
            callback(null, body);
            winston.log('info', `删除难度信息成功: ${url}请求时间:${response.elapsedTime}ms`);
        } else {
            var errMsg = {code: "00000", message: "删除难度信息失败" + url};
            winston.log('error', errMsg);
            return callback(errMsg, null);
        }
    });
};
//添加知识点信息
exports.addKnowledge = function (token, reqdata, callback) {
    var url;
    url = rootConfig.backendurl + 'basLearningPoint/add?token=' + token;
    request.post({url: url, body: JSON.stringify(reqdata)}, (error, response, body)=> {
        winston.log('info', 'backendurl:' + url);
        if (!error && response.statusCode === 200) {
            if (JSON.parse(body).responseCode == 'false') {
                var apierr = {code: "000001", message: "添加知识点信息接口返回错误" + url};
                winston.log('error', apierr);
            }
            callback(null, body);
            winston.log('info', `添加知识点信息成功: ${url}请求时间:${response.elapsedTime}ms`);

        } else {
            var errMsg = {code: "00000", message: "添加知识点信息失败" + url};

            winston.log('error', errMsg);
            callback(errMsg, null);
        }
    });
};

//分页查询知识点信息
exports.searchKnowledge = (token, reqdata, callback)=> {
    var obj, url;
    obj = {
        pageNum: reqdata.pageNum ? reqdata.pageNum : "1",
        pageSize: reqdata.pageSize ? reqdata.pageSize : "10",
        pointName: reqdata.pointName ? reqdata.pointName : "",
        stageName: reqdata.stageName ? reqdata.stageName : "",
        subjectName: reqdata.subjectName ? reqdata.subjectName : "",
        pointCode: reqdata.pointCode ? reqdata.pointCode : ""
    };
    url = rootConfig.backendurl + 'basLearningPoint/page?pageNum=' + obj.pageNum + '&pageSize=' + obj.pageSize + '&pointName=' + obj.pointName + '&stageName=' + obj.stageName + '&subjectName=' + obj.subjectName + '&pointCode=' + obj.pointCode + '&token=' + token;
    return request.get({
        url: url
    }, (error, response, body)=> {
        winston.log('info', 'backendurl:' + url);
        if (!error && response.statusCode === 200) {
            if (JSON.parse(body).responseCode == 'false') {
                var apierr = {code: "000001", message: "分页查询知识点信息接口返回错误" + url};
                winston.log('error', apierr);
            }
            callback(null, body);
            winston.log('info', `分页查询知识点信息成功: ${url}请求时间:${response.elapsedTime}ms`);

        } else {
            var errMsg = {code: "00000", message: "分页查询知识点信息失败" + url};

            winston.log('error', errMsg);
            callback(errMsg, null);
        }
    });
};

/**
 * 修改知识点信息
 * author：丽云
 */
exports.editKnowledge = (token, reqdata, callback)=> {
    var url;
    url = rootConfig.backendurl + 'basLearningPoint/update?token=' + token;
    request.put({url: url, body: JSON.stringify(reqdata)}, (error, response, body)=> {
        winston.log('info', 'backendurl:' + url);
        if (!error && response.statusCode === 200) {
            if (JSON.parse(body).responseCode == 'false') {
                var apierr = {code: "000001", message: "修改知识点信息接口返回错误" + url};
                winston.log('error', apierr);
            }
            callback(null, body);
            winston.log('info', `修改知识点信息成功: ${url}请求时间:${response.elapsedTime}ms`);

        } else {
            var errMsg = {code: "00000", message: "修改知识点信息失败" + url};

            winston.log('error', errMsg);
            callback(errMsg, null);
        }
    });
};
//删除知识点
exports.delKnowledge = function (token, pkid, callback) {
    var url;
    url = rootConfig.backendurl + 'basLearningPoint/status?ids=' + pkid + '&status=0&token=' + token;
    request.put({url: url}, (error, response, body)=> {
        winston.log('info', 'backendurl:' + url);
        if (!error && response.statusCode === 200) {
            if (JSON.parse(body).responseCode == 'false') {
                var apierr = {code: "000001", message: "删除知识点接口返回错误" + url};
                winston.log('error', apierr);
            }
            callback(null, body);
            winston.log('info', `删除知识点成功: ${url}请求时间:${response.elapsedTime}ms`);

        } else {
            var errMsg = {code: "00000", message: "删除知识点失败" + url};

            winston.log('error', errMsg);
            callback(errMsg, null);
        }
    });
};

//根据学科和学段查询知识点
exports.searchKnowledgeCode = function (subjectCode, stageCode, token, callback) {
    var url;
    url = rootConfig.backendurl + 'basLearningPoint/LpBySubAndSta?subjectCode=' + subjectCode + '&stageCode=' + stageCode + '&token=' + token;
    return request.get({
        url: url
    }, (error, response, body)=> {
        winston.log('info', 'backendurl:' + url);
        if (!error && response.statusCode === 200) {
            if (JSON.parse(body).responseCode == 'false') {
                var apierr = {code: "000001", message: "根据学科和学段查询知识点接口返回错误" + url};
                winston.log('error', apierr);
            }
            callback(null, body);
            winston.log('info', `根据学科和学段查询知识点成功: ${url}请求时间:${response.elapsedTime}ms`);

        } else {
            var errMsg = {code: "00000", message: "根据学科和学段查询知识点失败" + url};

            winston.log('error', errMsg);
            callback(errMsg, null);
        }
    });
};
//添加题型信息
exports.addType = function (reqdata, callback) {
    var url;
    url = rootConfig.backendurl + 'basQuestionType';
    return request.post({
        url: url,
        body: JSON.stringify(reqdata)
    }, (error, response, body)=> {
        winston.log('info', 'backendurl:' + url);
        if (!error && response.statusCode === 200) {
            if (JSON.parse(body).responseCode == 'false') {
                var apierr = {code: "000001", message: "添加题型信息接口返回错误" + url};
                winston.log('error', apierr);
            }
            callback(null, body);
            winston.log('info', `添加题型信息成功: ${url}请求时间:${response.elapsedTime}ms`);

        } else {
            var errMsg = {code: "00000", message: "添加题型信息失败" + url};

            winston.log('error', errMsg);
            callback(errMsg, null);
        }
    });
};
//分页查询题型信息
exports.searchType = (token, reqdata, callback)=> {
    var url;
    url = rootConfig.backendurl + 'basQuestionType/page?pageNum=' + reqdata.pagenum + '&pageSize=' + reqdata.pagesize + '&token=' + token;
    return request.get({
        url: url
    }, (error, response, body)=> {
        winston.log('info', 'backendurl:' + url);
        if (!error && response.statusCode === 200) {
            if (JSON.parse(body).responseCode == 'false') {
                var apierr = {code: "000001", message: "分页查询题型信息接口返回错误" + url};
                winston.log('error', apierr);
            }
            callback(null, body);
            winston.log('info', `分页查询题型信息成功: ${url}请求时间:${response.elapsedTime}ms`);

        } else {
            var errMsg = {code: "00000", message: "分页查询题型信息失败" + url};

            winston.log('error', errMsg);
            callback(errMsg, null);
        }
    });
};
//修改题型信息
exports.editType = function (reqdata, callback) {
    var url;
    url = rootConfig.backendurl + 'basQuestionType';
    return request.put({
        url: url,
        body: JSON.stringify(reqdata)
    }, (error, response, body)=> {
        winston.log('info', 'backendurl:' + url);
        if (!error && response.statusCode === 200) {
            if (JSON.parse(body).responseCode == 'false') {
                var apierr = {code: "000001", message: "修改题型信息接口返回错误" + url};
                winston.log('error', apierr);
            }
            callback(null, body);
            winston.log('info', `修改题型信息成功: ${url}请求时间:${response.elapsedTime}ms`);

        } else {
            var errMsg = {code: "00000", message: "修改题型信息失败" + url};

            winston.log('error', errMsg);
            callback(errMsg, null);
        }
    });
};
//删除题型信息
exports.delType = function (pkid, callback) {
    var url;
    url = rootConfig.backendurl + 'basQuestionType/status?ids=' + pkid + '&status=0';
    return request.put({
        url: url
    }, (error, response, body)=> {
        winston.log('info', 'backendurl:' + url);
        if (!error && response.statusCode === 200) {
            if (JSON.parse(body).responseCode == 'false') {
                var apierr = {code: "000001", message: "删除题型信息接口返回错误" + url};
                winston.log('error', apierr);
            }
            callback(null, body);
            winston.log('info', `删除题型信息成功: ${url}请求时间:${response.elapsedTime}ms`);

        } else {
            var errMsg = {code: "00000", message: "删除题型信息失败" + url};

            winston.log('error', errMsg);
            callback(errMsg, null);
        }
    });
};
//添加学科信息
exports.addSubject = function (reqdata, callback) {
    var url;
    url = rootConfig.backendurl + 'basSubject';
    return request.post({
        url: url,
        body: JSON.stringify(reqdata)
    }, (error, response, body)=> {
        winston.log('info', 'backendurl:' + url);
        if (!error && response.statusCode === 200) {
            if (JSON.parse(body).responseCode == 'false') {
                var apierr = {code: "000001", message: "添加学科信息接口返回错误" + url};
                winston.log('error', apierr);
            }
            callback(null, body);
            winston.log('info', `添加学科信息成功: ${url}请求时间:${response.elapsedTime}ms`);

        } else {
            var errMsg = {code: "00000", message: "添加学科信息失败" + url};

            winston.log('error', errMsg);
            callback(errMsg, null);
        }
    });
};
//分页查询学科信息
exports.searchSubject = (token, reqdata, callback)=> {
    var url;
    url = rootConfig.backendurl + 'basSubject/page?pageNum=' + reqdata.pagenum + '&pageSize=' + reqdata.pagesize + '&token=' + token;
    request.get({url: url}, (error, response, body)=> {
        winston.log('info', 'backendurl:' + url);
        if (!error && response.statusCode === 200) {
            if (JSON.parse(body).responseCode == 'false') {
                var apierr = {code: "000001", message: "分页查询学科信息接口返回错误" + url};
                winston.log('error', apierr);
            }
            callback(null, body);
            winston.log('info', `分页查询学科信息成功: ${url}请求时间:${response.elapsedTime}ms`);

        } else {
            var errMsg = {code: "00000", message: "分页查询学科信息失败" + url};

            winston.log('error', errMsg);
            callback(errMsg, null);
        }
    });
};
//修改学科信息
exports.editSubject = function (reqdata, callback) {
    var url;
    url = rootConfig.backendurl + 'basSubject';
    return request.put({
        url: url,
        body: JSON.stringify(reqdata)
    }, (error, response, body)=> {
        winston.log('info', 'backendurl:' + url);
        if (!error && response.statusCode === 200) {
            if (JSON.parse(body).responseCode == 'false') {
                var apierr = {code: "000001", message: "修改学科信息接口返回错误" + url};
                winston.log('error', apierr);
            }
            callback(null, body);
            winston.log('info', `修改学科信息成功: ${url}请求时间:${response.elapsedTime}ms`);

        } else {
            var errMsg = {code: "00000", message: "修改学科信息失败" + url};

            winston.log('error', errMsg);
            callback(errMsg, null);
        }
    });
};
//删除学科信息
exports.delSubject = function (pkid, callback) {
    var url;
    url = rootConfig.backendurl + 'basSubject/status?ids=' + pkid + '&status=0';
    return request.put({
        url: url
    }, (error, response, body)=> {
        winston.log('info', 'backendurl:' + url);
        if (!error && response.statusCode === 200) {
            if (JSON.parse(body).responseCode == 'false') {
                var apierr = {code: "000001", message: "删除学科信息接口返回错误" + url};
                winston.log('error', apierr);
            }
            callback(null, body);
            winston.log('info', `删除学科信息成功: ${url}请求时间:${response.elapsedTime}ms`);

        } else {
            var errMsg = {code: "00000", message: "删除学科信息失败" + url};

            winston.log('error', errMsg);
            callback(errMsg, null);
        }
    });
};
//添加属性信息
exports.addAttribute = function (reqdata, callback) {
    var url;
    url = rootConfig.backendurl + 'basAttrType';
    return request.post({
        url: url,
        body: JSON.stringify(reqdata)
    }, (error, response, body)=> {
        winston.log('info', 'backendurl:' + url);
        if (!error && response.statusCode === 200) {
            if (JSON.parse(body).responseCode == 'false') {
                var apierr = {code: "000001", message: "添加属性信息接口返回错误" + url};
                winston.log('error', apierr);
            }
            callback(null, body);
            winston.log('info', `添加属性信息成功: ${url}请求时间:${response.elapsedTime}ms`);

        } else {
            var errMsg = {code: "00000", message: "添加属性信息失败" + url};

            winston.log('error', errMsg);
            callback(errMsg, null);
        }
    });
};
//修改属性信息
exports.editAttribute = function (reqdata, callback) {
    var url;
    url = rootConfig.backendurl + 'basAttrType';
    return request.put({
        url: url,
        body: JSON.stringify(reqdata)
    }, (error, response, body)=> {
        winston.log('info', 'backendurl:' + url);
        if (!error && response.statusCode === 200) {
            if (JSON.parse(body).responseCode == 'false') {
                var apierr = {code: "000001", message: "修改属性信息接口返回错误" + url};
                winston.log('error', apierr);
            }
            callback(null, body);
            winston.log('info', `修改属性信息成功: ${url}请求时间:${response.elapsedTime}ms`);

        } else {
            var errMsg = {code: "00000", message: "修改属性信息失败" + url};

            winston.log('error', errMsg);
            callback(errMsg, null);
        }
    });
};
//查询属性分类信息
exports.searchAttribute = (token, reqdata, callback)=> {
    var url;
    url = rootConfig.backendurl + 'basAttrType/page?pageNum=' + reqdata.pagenum + '&pageSize=' + reqdata.pagesize + '&token=' + token;
    request.get({url: url}, (error, response, body)=> {
        winston.log('info', 'backendurl:' + url);
        if (!error && response.statusCode === 200) {
            if (JSON.parse(body).responseCode == 'false') {
                var apierr = {code: "000001", message: "查询属性分类信息接口返回错误" + url};
                winston.log('error', apierr);
            }
            callback(null, body);
            winston.log('info', `查询属性分类信息成功: ${url}请求时间:${response.elapsedTime}ms`);

        } else {
            var errMsg = {code: "00000", message: "查询属性分类信息失败" + url};

            winston.log('error', errMsg);
            callback(errMsg, null);
        }
    });
};
//删除属性分类信息
exports.delAttribute = function (pkid, callback) {
    var url;
    url = rootConfig.backendurl + 'basAttrType/status?ids=' + pkid + '&status=0';
    return request.put({
        url: url
    }, (error, response, body)=> {
        winston.log('info', 'backendurl:' + url);
        if (!error && response.statusCode === 200) {
            if (JSON.parse(body).responseCode == 'false') {
                var apierr = {code: "000001", message: "删除属性分类信息接口返回错误" + url};
                winston.log('error', apierr);
            }
            callback(null, body);
            winston.log('info', `删除属性分类信息成功: ${url}请求时间:${response.elapsedTime}ms`);

        } else {
            var errMsg = {code: "00000", message: "删除属性分类信息失败" + url};

            winston.log('error', errMsg);
            callback(errMsg, null);
        }
    });
};
//根据状态查询出年级信息
exports.searchAllGrade = (token, callback)=> {
    var url;
    url = rootConfig.backendurl + 'BasGrade/list?status=1&token=' + token;
    return request.get({
        url: url
    }, (error, response, body)=> {
        winston.log('info', 'backendurl:' + url);
        if (!error && response.statusCode === 200) {
            if (JSON.parse(body).responseCode == 'false') {
                var apierr = {code: "000001", message: "根据状态查询出年级信息接口返回错误" + url};
                winston.log('error', apierr);
            }
            callback(null, body);
            winston.log('info', `根据状态查询出年级信息成功: ${url}请求时间:${response.elapsedTime}ms`);

        } else {
            var errMsg = {code: "00000", message: "根据状态查询出年级信息失败" + url};

            winston.log('error', errMsg);
            callback(errMsg, null);
        }
    });
};
//添加年级信息
exports.addGrade = function (reqdata, callback) {
    var url;
    url = rootConfig.backendurl + 'BasGrade';
    return request.post({
        url: url,
        body: JSON.stringify(reqdata)
    }, (error, response, body)=> {
        winston.log('info', 'backendurl:' + url);
        if (!error && response.statusCode === 200) {
            if (JSON.parse(body).responseCode == 'false') {
                var apierr = {code: "000001", message: "添加年级信息接口返回错误" + url};
                winston.log('error', apierr);
            }
            callback(null, body);
            winston.log('info', `添加年级信息成功: ${url}请求时间:${response.elapsedTime}ms`);

        } else {
            var errMsg = {code: "00000", message: "添加年级信息失败" + url};

            winston.log('error', errMsg);
            callback(errMsg, null);
        }
    });
};
//删除年级信息
exports.delGrade = function (pkid, callback) {
    var url;
    url = rootConfig.backendurl + 'BasGrade/status?ids=' + pkid + '&status=0';
    return request.put({
        url: url
    }, (error, response, body)=> {
        winston.log('info', 'backendurl:' + url);
        if (!error && response.statusCode === 200) {
            if (JSON.parse(body).responseCode == 'false') {
                var apierr = {code: "000001", message: "删除年级信息接口返回错误" + url};
                winston.log('error', apierr);
            }
            callback(null, body);
            winston.log('info', `删除年级信息成功: ${url}请求时间:${response.elapsedTime}ms`);

        } else {
            var errMsg = {code: "00000", message: "删除年级信息失败" + url};

            winston.log('error', errMsg);
            callback(errMsg, null);
        }
    });
};
//修改年级信息
exports.editGrade = function (reqdata, callback) {
    var url;
    url = rootConfig.backendurl + 'BasGrade';
    return request.put({
        url: url,
        body: JSON.stringify(reqdata)
    }, (error, response, body)=> {
        winston.log('info', 'backendurl:' + url);
        if (!error && response.statusCode === 200) {
            if (JSON.parse(body).responseCode == 'false') {
                var apierr = {code: "000001", message: "修改年级信息接口返回错误" + url};
                winston.log('error', apierr);
            }
            callback(null, body);
            winston.log('info', `修改年级信息成功: ${url}请求时间:${response.elapsedTime}ms`);

        } else {
            var errMsg = {code: "00000", message: "修改年级信息失败" + url};

            winston.log('error', errMsg);
            callback(errMsg, null);
        }
    });
};
//查询学段信息
exports.searchAllStage = (token, callback)=> {
    var url;
    url = rootConfig.backendurl + 'BasStage/list?status=1&token=' + token;
    request.get({url: url}, (error, response, body)=> {
        winston.log('info', 'backendurl:' + url);
        if (!error && response.statusCode === 200) {
            if (JSON.parse(body).responseCode == 'false') {
                var apierr = {code: "000001", message: "查询学段信息接口返回错误" + url};
                winston.log('error', apierr);
            }
            callback(null, body);
            winston.log('info', `查询学段信息成功: ${url}请求时间:${response.elapsedTime}ms`);

        } else {
            var errMsg = {code: "00000", message: "查询学段信息失败" + url};

            winston.log('error', errMsg);
            callback(errMsg, null);
        }
    });
};
//添加学段信息
exports.addStage = function (reqdata, callback) {
    var url;
    url = rootConfig.backendurl + 'BasStage';
    return request.post({
        url: url,
        body: JSON.stringify(reqdata)
    }, (error, response, body)=> {
        winston.log('info', 'backendurl:' + url);
        if (!error && response.statusCode === 200) {
            if (JSON.parse(body).responseCode == 'false') {
                var apierr = {code: "000001", message: "添加学段信息接口返回错误" + url};
                winston.log('error', apierr);
            }
            callback(null, body);
            winston.log('info', `添加学段信息成功: ${url}请求时间:${response.elapsedTime}ms`);

        } else {
            var errMsg = {code: "00000", message: "添加学段信息失败" + url};

            winston.log('error', errMsg);
            callback(errMsg, null);
        }
    });
};
//修改学段信息
exports.editStage = function (reqdata, callback) {
    var url;
    url = rootConfig.backendurl + 'BasStage';
    return request.put({
        url: url,
        body: JSON.stringify(reqdata)
    }, (error, response, body)=> {
        winston.log('info', 'backendurl:' + url);
        if (!error && response.statusCode === 200) {
            if (JSON.parse(body).responseCode == 'false') {
                var apierr = {code: "000001", message: "修改学段信息接口返回错误" + url};
                winston.log('error', apierr);
            }
            callback(null, body);
            winston.log('info', `修改学段信息成功: ${url}请求时间:${response.elapsedTime}ms`);

        } else {
            var errMsg = {code: "00000", message: "修改学段信息失败" + url};

            winston.log('error', errMsg);
            callback(errMsg, null);
        }
    });
};
//删除学段信息
exports.delStage = function (pkid, callback) {
    var url;
    url = rootConfig.backendurl + 'BasStage/status?ids=' + pkid + '&status=0';
    return request.put({
        url: url
    }, (error, response, body)=> {
        winston.log('info', 'backendurl:' + url);
        if (!error && response.statusCode === 200) {
            if (JSON.parse(body).responseCode == 'false') {
                var apierr = {code: "000001", message: "删除学段信息接口返回错误" + url};
                winston.log('error', apierr);
            }
            callback(null, body);
            winston.log('info', `删除学段信息成功: ${url}请求时间:${response.elapsedTime}ms`);

        } else {
            var errMsg = {code: "00000", message: "删除学段信息失败" + url};

            winston.log('error', errMsg);
            callback(errMsg, null);
        }
    });
};
//根据状态查询学科信息
exports.searchAllSubject = (token, callback)=> {
    var url;
    url = rootConfig.backendurl + 'basSubject/list?status=1&token=' + token;
    return request.get({